<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <title>聊天页面-信息列表</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/common.css" />
    <link rel="stylesheet" type="text/css" href="../../css/aui-pull-refresh.css" />
    <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    <style>
        html,
        body {
            width: 100%;
            min-height: 100%;
            background: #f2efed;
            line-height: 1;
        }



        .change_name_box{
          padding: 2rem 0.75rem;
        }
        .title{
          font-size: 0.8rem;
          color: #333;
        }
        .change_box{
          padding: 0.7rem 0 0.2rem 0;
          font-size: 0.8rem;
          color: #333;
          border-bottom: 1px solid #f23030;
        }
    </style>
</head>

<body>
 <div class="change_name_box">
   <div class="title">群聊名字</div>
   <div class="change_box" contenteditable="true">这里是群名字</div>
 </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/jquery.min.js"></script>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript" src="../../script/utils.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/aui-tab.js"></script>
<script type="text/javascript" src="../../script/aui-scroll.js"></script>
<script type="text/javascript" src="../../script/aui-pull-refresh.js"></script>
<script type="text/javascript">


    apiready = function() {
      $('.change_box').text(api.pageParam.group_name)
    };


    // 保存新的群名字
    function save_group_name(){
      api.ajax({
          url: window.Url.Community_editFriend,
          method: 'post',
          data: {
              values: {
                   token:$api.getStorage('user_data').token,
                   groupchat_id:api.pageParam.group_chat_id,
                   type:2,
                   remarks:$('.change_box').html(),
                   name:$('.change_box').html()
              }
          }
      },function(ret, err){
          if (ret) {
              api.toast({
                  msg: ret.info,
                  duration: 2000,
                  location: 'bottom'
              });

              setTimeout(function(){
                api.closeWin({});
              },2000)

              //刷新群资料的页面
              api.execScript({
                  name: 'four_one_header2',
                  frameName: 'chat_group_detail',
                  script: 'window.location.reload();'
              });

              api.execScript({
                  name: 'four_one_header',
                  frameName: 'my_chat_group',
                  script: 'window.location.reload();'
              });

              var name =""+$('.change_box').html();

              api.execScript({
                  name: 'group_chat_header',
                  script: "change_group_name(\'" + name + "\')"
              });



          } else {
              alert( JSON.stringify( err ) );
          }
      });


    }
</script>

</html>
